package com.topisv.tms.web.account;

import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springside.modules.web.Servlets;

import com.topisv.tms.entity.Customers;
import com.topisv.tms.entity.User;
import com.topisv.tms.entity.lightShelf.LightShelf;
import com.topisv.tms.entity.lightShelf.LightShelfStock;
import com.topisv.tms.entity.message.Message;
import com.topisv.tms.service.CustomersService;
import com.topisv.tms.service.UserService;
import com.topisv.tms.service.account.AccountService;
import com.topisv.tms.service.account.ShiroDbRealm.ShiroUser;
import com.topisv.tms.service.lightShelf.LightShelfService;
import com.topisv.tms.service.lightShelf.LightShelfStockService;
import com.topisv.tms.service.message.MessageService;
import com.topisv.tms.utils.JsonUtil;
import com.topisv.tms.web.base.BaseDataTableController;

/**
 * 用户_control
 * @author ch
 */
@Controller
@RequestMapping({ "/user" })
public class UserController extends BaseDataTableController{

	private static final Logger logger = LoggerFactory.getLogger(UserController.class);

	@Autowired
	private UserService userService;
	@Autowired
	private MessageService messageService;
	
	
	/**
	 * 查询站内信
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "ajaxQueryMessage")
	public String ajaxQueryMessage(ServletRequest request,HttpServletResponse response) {
		try {
			String jobuuid=request.getParameter("jobuuid");
			List<Message> messageList=this.messageService.loadByJobuuid(jobuuid);
			
			Map<String,Object> map = new HashMap<String,Object>();
			map.put("messageList", messageList);
			String json = JsonUtil.getObjectString(map);
			PrintWriter out;
			out = response.getWriter();
			out.print(json);
		} catch (Exception e) {
			
			logger.error("error",e);
		}
		return null;
	}
}


